package cn.saltybe.analysis.crawler;

import com.gargoylesoftware.htmlunit.ScriptException;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.javascript.JavaScriptErrorListener;

import java.net.MalformedURLException;
import java.net.URL;

public class GeccoJavaScriptErrorListener implements JavaScriptErrorListener {
    @Override
    public void scriptException(HtmlPage htmlPage, ScriptException e) {
        System.out.println("Script Exception: " + e.getMessage() + " in " + htmlPage.getUrl());
    }

    @Override
    public void timeoutError(HtmlPage htmlPage, long l, long l1) {
        System.out.println("Caught Timeout Error: allowed " + l + ", already elapsed  " + l1 + " in " + htmlPage.getUrl());
    }

    @Override
    public void malformedScriptURL(HtmlPage htmlPage, String s, MalformedURLException e) {

    }

    @Override
    public void loadScriptError(HtmlPage htmlPage, URL url, Exception e) {
        System.out.println("Load Script Error: " + e.getMessage() + " in " + url);
    }

    @Override
    public void warn(String s, String s1, int i, String s2, int i1) {

    }
}
